package com.capgemini.cn.authority.data.entity;

import com.capgemini.cn.authority.data.core.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * <p>资源表，用以存储与客户端约定好的资源标识</p>
 * Created at 2017/8/23
 *
 * @author Andriy
 */
@Entity
@Table(name = "cg_asserts")
@NoArgsConstructor
@AllArgsConstructor
public class Asserts extends BaseEntity {

    /**
     * 资源名称
     */
    @Column(name = "assert_name", length = 50, nullable = false)
    @Getter
    @Setter
    private String assertName;

    /**
     * 资源值，需与资源方保持一致（可以是元素的唯一编码、URL等）
     */
    @Column(name = "assert_value", length = 50, nullable = false, unique = true)
    @Getter
    @Setter
    private String assertValue;

    /**
     * 资源所在的组信息
     */
    @ManyToOne(targetEntity = AssertsGroup.class, optional = false, fetch = FetchType.LAZY)
    @JoinColumn(name = "assert_group_id", referencedColumnName = "id", nullable = false)
    @Getter
    @Setter
    private AssertsGroup assertsGroup;
}
